<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<!-- 引入 Bootstrap -->
<link href="../../style/bootstrap-4.6.0-dist/css/bootstrap.css" rel="stylesheet">
<link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<style>
    h1{
        text-align: center;
    }
    #checkAll, .check {
        width: 20px;
        height: 20px;
    }
    #add_btn {
        background: #009688;
        height: 43px;
        width: 82px;
        border-radius: 10px;
        cursor: pointer;
        color: #FBFBFB;
        margin-right: 10px;
    }
    #del_btn {
        background: #e4606d;
        height: 43px;
        width: 82px;
        border-radius: 10px;
        cursor: pointer;
        color: #FBFBFB;
        margin-top: 10px;
        margin-left: 20px;
    }
    /*搜索框1*/
    .bar1 {
        width: 455px;
        height: 40px;
        display: inline-block;
        margin-left: 33px;
    }

    #jobTitle {
        width: 285px;
        height: 40px;
        color: #0f6674;
        font-weight: bold;
        border-radius: 7px;
    }

    #sous_btn {
        display: inline-block;
        width: 40px;
        height: 40px;
        margin-right: 56px;
    }

    #sous_form {
        width: 810px;
    }

    .bar1 input {
        border: 2px solid #7BA7AB;
        border-radius: 5px;
        background: #F9F0DA;
        color: #9E9C9C;
    }

    .bar1 button {
        top: 0;
        right: 0;
        background: #7BA7AB;
        border-radius: 0 5px 5px 0;
    }

    .bar1 button:before {
        content: "\f002";
        font-family: FontAwesome;
        font-size: 16px;
        color: #F9F0DA;
    }
    label {
        font-weight: bold;
        font-size: 20px;
    }
    #tr_text td{
        font-weight: bold;
    }
    #menu-tab{
        margin-top: 15px;
        background: #f8f9fa;
    }

</style>
<body>
<div id="menuContent">
    <div class="container-fluid">
        <!--   row   一行  -->
        <div class="row">
            <div class="col-xl-12" id="top_div">
                <div class="search bar1">
                    <form id="sous_form">
                        <label>菜单名：</label>
                        <input id="jobTitle" name="jobTitle" type="text" placeholder="按菜单名称搜索...">
                        <button id="sous_btn" type="button"></button>
                    </form>
                </div>
                <button type="button" id="add_btn">
                    添加
                </button>
                <button type="button" id="del_btn">删除</button>
            </div>
        </div>
    </div>
    <table id="menu-tab" class="table table-hover">
        <tr id="tr_text">
            <td><input type="checkbox" id="checkAll" @click="allCheck"></td>
            <td>菜单ID</td>
            <td>菜单名称</td>
            <td>菜单路径</td>
            <td>菜单Pid</td>
        </tr>
    <!--  page.list  page类的list  -->
        <tr v-for="menu in page.list" id="tr_text2">
            <td><input @click="isCheckAll" type="checkbox" :value="menu.menuId" class="check"></td>
            <td>{{menu.menuId}}</td>
            <td>{{menu.menuName}}</td>
            <td>{{menu.menuUrl}}</td>
            <td>{{menu.menuPid}}</td>
        </tr>
    </table>
    <!--无序列表 翻页-->
    <ul class="pagination">
        <li class="page-item"><a class="page-link" href="javascript:void(0);" @click="toPage(1)">首页</a></li>
        <li class="page-item"><a class="page-link" href="javascript:void(0);" v-if="page.pageNow>1"
                                 @click="toPage(page.pageNow-1)">{{page.pageNow-1}}</a></li>
        <li class="page-item active"><a class="page-link" href="javascript:void(0);">{{page.pageNow}}</a></li>
        <li class="page-item"><a class="page-link" href="javascript:void(0);" v-if="page.pageNow<page.pageTotal"
                                 @click="toPage(page.pageNow+1)">{{page.pageNow+1}}</a></li>
        <li class="page-item"><a class="page-link" href="javascript:void(0);" @click="toPage(page.pageTotal)">尾页</a>
        </li>
    </ul>
</div>

    <script src="../../style/jquery-3.3.1.js"></script>
    <script src="../../style/bootstrap-4.6.0-dist/js/bootstrap.js"></script>
    <script src="../../style/vue.js"></script>
    <script src="../../my1.1.js"></script>
    <script>
        $(function () {
            let page = selMenuTable(1);
            let app = new Vue({
                el: '#menuContent',
                data: {
                    page: page
                },
                methods: {
                    allCheck: function () {
                        eventHub.$emit('allCheck', null);
                    },
                    isCheckAll: function () {
                        eventHub.$emit('isCheckAll', null);
                    },
                    toPage: function (pageNow) {//当前页
                        this.page = selMenuTable(pageNow);
                    }
                }
            })
        })

        function selMenuTable(pageNow) {
            let page;//声明，然后在上边调用
            $.ajax({
                type: "post",
                data: {pageNow: pageNow},
                url: "../../Menu/selMenuTable",
                async: false,
                dataType: "json",
                success: function (json) {
                    page = json; //把json对象赋值给data,然后返回
                }
            })
            return page;
        }
    </script>
</body>
</html>